using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

namespace ConfigurationSettings
{
    /// <summary>
    /// Binary configuration class used to store various settings for the application.
    /// </summary>
    [Serializable]
    public class FileTrackerConfiguration : ConfigurationBase
    {

        #region ** Member Variables **

        #region *** Other Member Variables ***

        private bool _askBeforeDelete = true;

        private Dictionary<string, string> _favoriteList;
        private Dictionary<KeyEnum, Keys> _keyList;
        private bool _leftAutoSort = true;

        private string _leftDefaultFolder;
        private FolderType _leftDefaultFolderType = FolderType.SpecificFolder;
        private Column _leftDefaultSortColumn = Column.Name;
        private int _mainSplitterDistance = 584;
        private Point _mainWindowLocation = new Point(10, 10);
        private Size _mainWindowSize = new Size(1181, 712);
        private Point _preferenceWindowLocation = new Point(2, 2);
        private Size _preferenceWindowSize = new Size(623, 594);
        private int _preferencesSplitterDistance = 146;
        private Dictionary<string, string> _programList;
        private bool _rightAutoSort = true;
        private string _rightDefaultFolder;
        private FolderType _rightDefaultFolderType = FolderType.SpecificFolder;
        private Column _rightDefaultSortColumn = Column.Name;
        private int _sizePrecision = 2;
        private SizeUnitType _sizeUnit = SizeUnitType.Kilobytes;

        #endregion

        #region *** Colors ***

        private ColumnExtendedProperties _columnSettings;
        private ItemSettings _directorySettings;
        private ItemSettings _fileSettings;
        private Color _focusColor = Color.FromArgb(0x020, Color.Red);
        private Color _listViewBackColor = Color.White;

        #endregion

        #endregion

        #region ** Properties **

        #region *** Other Properties ***

        //public Version AssemblyVersion
        //{
        //    get
        //    {
        //        return AssemblyVersion;
        //    }
        //}

        public Point MainWindowLocation
        {
            get { return _mainWindowLocation; }

            set
            {
                _mainWindowLocation = value;
                if (_mainWindowLocation.X < 0)
                {
                    _mainWindowLocation.X = 0;
                }
                if (_mainWindowLocation.Y < 0)
                {
                    _mainWindowLocation.Y = 0;
                }
            }
        }

        public Size MainWindowSize
        {
            get { return _mainWindowSize; }
            set
            {
                _mainWindowSize = value;
                if (_mainWindowSize.Width < 733)
                {
                    _mainWindowSize.Width = 733;
                }
                if (_mainWindowSize.Height < 221)
                {
                    _mainWindowSize.Height = 221;
                }
            }
        }

        public int MainSplitterDistance
        {
            get { return _mainSplitterDistance; }
            set { _mainSplitterDistance = value; }
        }

        public Point PreferenceWindowLocation
        {
            get { return _preferenceWindowLocation; }
            set { _preferenceWindowLocation = value; }
        }

        public Size PreferenceWindowSize
        {
            get { return _preferenceWindowSize; }
            set { _preferenceWindowSize = value; }
        }

        public int PreferencesSplitterDistance
        {
            get { return _preferencesSplitterDistance; }
            set { _preferencesSplitterDistance = value; }
        }

        public SizeUnitType SizeUnit
        {
            get { return _sizeUnit; }
            set { _sizeUnit = value; }
        }

        public int SizePrecision
        {
            get { return _sizePrecision; }
            set { _sizePrecision = value; }
        }

        #endregion

        #region *** Colors ***

        public Color FocusColor
        {
            get { return _focusColor; }
            set { _focusColor = value; }
        }

        public Color ListViewBackColor
        {
            get { return _listViewBackColor; }

            set { _listViewBackColor = value; }
        }

        public ItemSettings FileSettings
        {
            get { return _fileSettings; }
            set { _fileSettings = value; }
        }

        public ItemSettings DirectorySettings
        {
            get { return _directorySettings; }
            set { _directorySettings = value; }
        }

        public ColumnExtendedProperties ColumnSettings
        {
            get { return _columnSettings; }
            set { _columnSettings = value; }
        }

        #endregion

        #region ** General FileTrackerConfiguration **

        public bool AskBeforeDelete
        {
            get { return _askBeforeDelete; }

            set { _askBeforeDelete = value; }
        }

        public bool LeftAutoSort
        {
            get { return _leftAutoSort; }
            set { _leftAutoSort = value; }
        }

        public bool RightAutoSort
        {
            get { return _rightAutoSort; }
            set { _rightAutoSort = value; }
        }

        public string LeftDefaultFolder
        {
            get { return _leftDefaultFolder; }

            set { _leftDefaultFolder = value; }
        }

        public FolderType LeftDefaultFolderType
        {
            get { return _leftDefaultFolderType; }

            set { _leftDefaultFolderType = value; }
        }

        public string RightDefaultFolder
        {
            get { return _rightDefaultFolder; }

            set { _rightDefaultFolder = value; }
        }

        public FolderType RightDefaultFolderType
        {
            get { return _rightDefaultFolderType; }

            set { _rightDefaultFolderType = value; }
        }

        public Column LeftDefaultSortColumn
        {
            get { return _leftDefaultSortColumn; }

            set { _leftDefaultSortColumn = value; }
        }

        public Column RightDefaultSortColumn
        {
            get { return _rightDefaultSortColumn; }

            set { _rightDefaultSortColumn = value; }
        }

        #endregion

        #region ** Favorites and OpenWith **

        public Dictionary<string, string> FavoriteList
        {
            get { return _favoriteList; }
        }

        public Dictionary<string, string> ProgramList
        {
            get { return _programList; }
        }

        public Dictionary<KeyEnum, Keys> KeyList
        {
            get { return _keyList; }
        }

        #endregion

        #endregion

        public FileTrackerConfiguration()
        {
            {
                Version tempVersion = Assembly.GetExecutingAssembly().GetName().Version;
                _assemblyVersion = new Version(tempVersion.Major, tempVersion.Minor, tempVersion.Build, 0);

                _favoriteList = new Dictionary<string, string>();
                _programList = new Dictionary<string, string>();
                _keyList = new Dictionary<KeyEnum, Keys>
                    {
                        {KeyEnum.COPY, Keys.None},
                        {KeyEnum.DELETE, Keys.None},
                        {KeyEnum.MAKEDIR, Keys.None},
                        {KeyEnum.MOVE, Keys.None},
                        {KeyEnum.REFRESH, Keys.None},
                        {KeyEnum.RENAME, Keys.None},
                        {KeyEnum.TOUCH, Keys.None}
                    };

                DirectoryInfo tempDirInfo = new DirectoryInfo(Application.UserAppDataPath);
                _leftDefaultFolder = tempDirInfo.Root.FullName;
                _rightDefaultFolder = tempDirInfo.Root.FullName;

                _fileSettings = new ItemSettings();


                #region ** Plain Settings **

                _fileSettings.PlainSettings.NameColors.Color1 = Color.FromArgb(205, 235, 255);
                _fileSettings.PlainSettings.NameColors.Color2 = Color.FromArgb(235, 245, 255);
                _fileSettings.PlainSettings.NameColors.Direction = 90.0F;

                _fileSettings.PlainSettings.SizeColors.Color1 = Color.FromArgb(205, 235, 255);
                _fileSettings.PlainSettings.SizeColors.Color2 = Color.FromArgb(235, 245, 255);
                _fileSettings.PlainSettings.SizeColors.Direction = 90.0F;

                _fileSettings.PlainSettings.DateColors.Color1 = Color.FromArgb(205, 235, 255);
                _fileSettings.PlainSettings.DateColors.Color2 = Color.FromArgb(235, 245, 255);
                _fileSettings.PlainSettings.DateColors.Direction = 90.0F;

                _fileSettings.PlainSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _fileSettings.PlainSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion

                #region ** Selected Settings **

                _fileSettings.SelectedSettings.NameColors.Color1 = Color.FromArgb(180, 235, 255);
                _fileSettings.SelectedSettings.NameColors.Color2 = Color.FromArgb(200, 240, 255);
                _fileSettings.SelectedSettings.NameColors.Direction = 90.0F;

                _fileSettings.SelectedSettings.SizeColors.Color1 = Color.FromArgb(180, 235, 255);
                _fileSettings.SelectedSettings.SizeColors.Color2 = Color.FromArgb(200, 240, 255);
                _fileSettings.SelectedSettings.SizeColors.Direction = 90.0F;

                _fileSettings.SelectedSettings.DateColors.Color1 = Color.FromArgb(180, 235, 255);
                _fileSettings.SelectedSettings.DateColors.Color2 = Color.FromArgb(200, 240, 255);
                _fileSettings.SelectedSettings.DateColors.Direction = 90.0F;

                _fileSettings.SelectedSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _fileSettings.SelectedSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion

                #region ** MouseOver Settings **

                _fileSettings.MouseOverSettings.NameColors.Color1 = Color.FromArgb(190, 230, 255);
                _fileSettings.MouseOverSettings.NameColors.Color2 = Color.FromArgb(220, 240, 255);
                _fileSettings.MouseOverSettings.NameColors.Direction = 90.0F;

                _fileSettings.MouseOverSettings.SizeColors.Color1 = Color.FromArgb(190, 230, 255);
                _fileSettings.MouseOverSettings.SizeColors.Color2 = Color.FromArgb(220, 240, 255);
                _fileSettings.MouseOverSettings.SizeColors.Direction = 90.0F;

                _fileSettings.MouseOverSettings.DateColors.Color1 = Color.FromArgb(190, 230, 255);
                _fileSettings.MouseOverSettings.DateColors.Color2 = Color.FromArgb(220, 240, 255);
                _fileSettings.MouseOverSettings.DateColors.Direction = 90.0F;

                _fileSettings.MouseOverSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _fileSettings.MouseOverSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion

                #region ** Selected MouseOver Settings **

                _fileSettings.SelectedMouseOverSettings.NameColors.Color1 = Color.FromArgb(150, 230, 255);
                _fileSettings.SelectedMouseOverSettings.NameColors.Color2 = Color.FromArgb(175, 235, 255);
                _fileSettings.SelectedMouseOverSettings.NameColors.Direction = 90.0F;

                _fileSettings.SelectedMouseOverSettings.SizeColors.Color1 = Color.FromArgb(150, 230, 255);
                _fileSettings.SelectedMouseOverSettings.SizeColors.Color2 = Color.FromArgb(175, 235, 255);
                _fileSettings.SelectedMouseOverSettings.SizeColors.Direction = 90.0F;

                _fileSettings.SelectedMouseOverSettings.DateColors.Color1 = Color.FromArgb(150, 230, 255);
                _fileSettings.SelectedMouseOverSettings.DateColors.Color2 = Color.FromArgb(175, 235, 255);
                _fileSettings.SelectedMouseOverSettings.DateColors.Direction = 90.0F;

                _fileSettings.SelectedMouseOverSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _fileSettings.SelectedMouseOverSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion

                _directorySettings = new ItemSettings();

                #region ** Plain Settings **

                _directorySettings.PlainSettings.NameColors.Color1 = Color.FromArgb(213, 255, 213);
                _directorySettings.PlainSettings.NameColors.Color2 = Color.FromArgb(213, 255, 223);
                _directorySettings.PlainSettings.NameColors.Direction = 0.0F;

                _directorySettings.PlainSettings.SizeColors.Color1 = Color.FromArgb(213, 255, 223);
                _directorySettings.PlainSettings.SizeColors.Color2 = Color.FromArgb(213, 255, 234);
                _directorySettings.PlainSettings.SizeColors.Direction = 0.0F;

                _directorySettings.PlainSettings.DateColors.Color1 = Color.FromArgb(213, 255, 234);
                _directorySettings.PlainSettings.DateColors.Color2 = Color.FromArgb(213, 255, 244);
                _directorySettings.PlainSettings.DateColors.Direction = 0.0F;

                _directorySettings.PlainSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _directorySettings.PlainSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion

                #region ** Selected Settings **

                _directorySettings.SelectedSettings.NameColors.Color1 = Color.FromArgb(170, 255, 170);
                _directorySettings.SelectedSettings.NameColors.Color2 = Color.FromArgb(170, 255, 191);
                _directorySettings.SelectedSettings.NameColors.Direction = 0.0F;

                _directorySettings.SelectedSettings.SizeColors.Color1 = Color.FromArgb(170, 255, 191);
                _directorySettings.SelectedSettings.SizeColors.Color2 = Color.FromArgb(170, 255, 213);
                _directorySettings.SelectedSettings.SizeColors.Direction = 0.0F;

                _directorySettings.SelectedSettings.DateColors.Color1 = Color.FromArgb(170, 255, 213);
                _directorySettings.SelectedSettings.DateColors.Color2 = Color.FromArgb(179, 255, 234);
                _directorySettings.SelectedSettings.DateColors.Direction = 0.0F;

                _directorySettings.SelectedSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _directorySettings.SelectedSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion

                #region ** MouseOver Settings **

                _directorySettings.MouseOverSettings.NameColors.Color1 = Color.FromArgb(191, 255, 191);
                _directorySettings.MouseOverSettings.NameColors.Color2 = Color.FromArgb(191, 255, 209);
                _directorySettings.MouseOverSettings.NameColors.Direction = 0.0F;

                _directorySettings.MouseOverSettings.SizeColors.Color1 = Color.FromArgb(191, 255, 209);
                _directorySettings.MouseOverSettings.SizeColors.Color2 = Color.FromArgb(191, 255, 223);
                _directorySettings.MouseOverSettings.SizeColors.Direction = 0.0F;

                _directorySettings.MouseOverSettings.DateColors.Color1 = Color.FromArgb(191, 255, 223);
                _directorySettings.MouseOverSettings.DateColors.Color2 = Color.FromArgb(191, 255, 239);
                _directorySettings.MouseOverSettings.DateColors.Direction = 0.0F;

                _directorySettings.MouseOverSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _directorySettings.MouseOverSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion

                #region ** Selected MouseOver Settings **

                _directorySettings.SelectedMouseOverSettings.NameColors.Color1 = Color.FromArgb(149, 255, 149);
                _directorySettings.SelectedMouseOverSettings.NameColors.Color2 = Color.FromArgb(149, 255, 175);
                _directorySettings.SelectedMouseOverSettings.NameColors.Direction = 0.0F;

                _directorySettings.SelectedMouseOverSettings.SizeColors.Color1 = Color.FromArgb(149, 255, 175);
                _directorySettings.SelectedMouseOverSettings.SizeColors.Color2 = Color.FromArgb(149, 255, 202);
                _directorySettings.SelectedMouseOverSettings.SizeColors.Direction = 0.0F;

                _directorySettings.SelectedMouseOverSettings.DateColors.Color1 = Color.FromArgb(149, 255, 202);
                _directorySettings.SelectedMouseOverSettings.DateColors.Color2 = Color.FromArgb(149, 255, 228);
                _directorySettings.SelectedMouseOverSettings.DateColors.Direction = 0.0F;

                _directorySettings.SelectedMouseOverSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _directorySettings.SelectedMouseOverSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion

                _columnSettings = new ColumnExtendedProperties();

                #region ** Plain Colors **

                _columnSettings.PlainSettings.NameColors.Color1 = Color.FromArgb(192, 192, 192);
                _columnSettings.PlainSettings.NameColors.Color2 = Color.FromArgb(192, 192, 255);
                _columnSettings.PlainSettings.NameColors.Direction = 0;

                _columnSettings.PlainSettings.SizeColors.Color1 = Color.FromArgb(192, 192, 255);
                _columnSettings.PlainSettings.SizeColors.Color2 = Color.FromArgb(255, 192, 192);
                _columnSettings.PlainSettings.SizeColors.Direction = 0;

                _columnSettings.PlainSettings.DateColors.Color1 = Color.FromArgb(255, 192, 192);
                _columnSettings.PlainSettings.DateColors.Color2 = Color.FromArgb(192, 192, 192);
                _columnSettings.PlainSettings.DateColors.Direction = 0;

                _columnSettings.PlainSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _columnSettings.PlainSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion

                #region ** Highlight Colors **

                _columnSettings.HighlightSettings.NameColors.Color1 = Color.FromArgb(160, 160, 160);
                _columnSettings.HighlightSettings.NameColors.Color2 = Color.FromArgb(160, 160, 255);
                _columnSettings.HighlightSettings.NameColors.Direction = 0;

                _columnSettings.HighlightSettings.SizeColors.Color1 = Color.FromArgb(160, 160, 255);
                _columnSettings.HighlightSettings.SizeColors.Color2 = Color.FromArgb(255, 160, 160);
                _columnSettings.HighlightSettings.SizeColors.Direction = 0;

                _columnSettings.HighlightSettings.DateColors.Color1 = Color.FromArgb(255, 160, 160);
                _columnSettings.HighlightSettings.DateColors.Color2 = Color.FromArgb(160, 160, 160);
                _columnSettings.HighlightSettings.DateColors.Direction = 0;

                _columnSettings.HighlightSettings.Font = new Font("Courier New", 9.75F, FontStyle.Regular);
                _columnSettings.HighlightSettings.FontColor = Color.FromKnownColor(KnownColor.ControlText);

                #endregion
            }
        }


        //public static implicit operator FileTrackerConfiguration(Configuration_2_5_9 OldConfig)
        //{
        //    FileTrackerConfiguration NewConfig;
        //    NewConfig = new FileTrackerConfiguration();

        //
        //    return NewConfig;
        //}
    }

    //[Serializable()]
    //public class FileTrackerConfiguration : FileTrackerConfiguration0210
    //{
    //    protected string _tempProp;

    //    public string TempProp
    //    {
    //        get { return _tempProp; }
    //    }
    //}
}